草庐IT

ASP.NET MVC - 安全

全部标签

c# - C# -ASP.NET 中的一些性能 [注意事项/注意事项] 是什么

我正在完成我的一个项目并查看整个项目以寻找错误、错误和性能错误。我正在使用MVC。我捕获了一个不要,那就是:切勿将RenderPartial放入循环中。它会大大降低整个服务器的速度。 最佳答案 从不将WebControl存储到Session。因为它有对Page对象的引用,所以它最终将每个控件存储到session中。 关于c#-C#-ASP.NET中的一些性能[注意事项/注意事项]是什么,我们在StackOverflow上找到一个类似的问题: https://s

c# - 在 ASP.NET MVC 中测试时如何访问 JsonResult 数据

我在C#mvcController中有这段代码:[HttpPost]publicActionResultDelete(stringrunId){if(runId==""||runId==null){returnthis.Json(new{error="Nulloremptyparams"});}try{intuserId=(int)Session["UserId"];intrun=Convert.ToInt32(runId);CloudMgrcloud=newCloudMgr(Session);cloud.DeleteRun(userId,run);returnthis.Json(ne

C#:这个字段赋值安全吗?

在这段代码中:classClassWithConstants{privateconststringConstantA="Something";privateconststringConstantB=ConstantA+"Else";...}是否存在以ConstantB=="Else"结束的风险?还是线性分配? 最佳答案 你总会得到“SomethingElse”。这是因为ConstantB依赖于ConstantA。你甚至可以换行,你会得到相同的结果。编译器知道ConstantB依赖于ConstantA并会相应地处理它,即使您将它写在分

c# - ASP.NET C# ListBox 服务器控件不会禁用

我有4个服务器端ListBox控件。所有这些都将其Enabled属性设置为false,但在呈现时它们肯定是启用的。它们都是多选的。这些没有数据绑定(bind)或触摸它们背后的任何代码。下面是所有这些的标记(保存ID)。我正在使用IIS6运行.NETFrameworkv4。这是运行时生成的标记: 最佳答案 我找到了一个解决方案。在web.config部分,您必须添加.在Asp.net4.0中,任何不接受特定用户输入(文本框或密码)的控件都不会使用disabled="disabled"呈现。Control.Enabled=false时的

c# - 我需要在 C# .Net 中创建一个线程安全的静态变量

好吧,它比问题复杂一点。classA{staticintneedsToBeThreadSafe=0;publicstaticvoidM1(){needsToBeThreadSafe=RandomNumber();}publicstaticvoidM2(){print(needsToBeThreadSafe);}}现在我要求在M1()和M2()之间调用“needsToBeThreadSafe”保持线程安全。 最佳答案 怎么样:publicstaticvoidM1(){Interlocked.Exchange(refneedsToBeT

c# - Asp.Net MVC4 + Web API Controller 删除请求 >> 404 错误

我有一个VS2012MVC4解决方案,我在其中测试WebAPIController。我成功地测试了GET、POST、PUT,但DELETE仍然给我一个http404错误。当我在我的apiController中的“DeleteMovie”操作中设置断点时,断点永远不会到达。我看了很多关于这个问题的帖子,但没有人帮助我。这是我用于删除的APIController:[HttpDelete]publicHttpResponseMessageDeleteMovie(intid){//Deletethemoviefromthedatabase//ReturnstatuscodereturnnewH

c# - 当部分 View 位于共享文件夹中时,ASP.NET MVC '@model dynamic' 无法识别模型属性

不重复:MVCRazordynamicmodel,'object'doesnotcontaindefinitionfor'PropertyName'根据那里的答案,AccordingtoDavidEbbo,youcan'tpassananonymoustypeintoadynamically-typedviewbecausetheanonymoustypesarecompiledasinternal.SincetheCSHTMLviewiscompiledintoaseparateassembly,itcan'taccesstheanonymoustype'sproperties.为什

c# - ASP.NET Web API Authentication.GetExternalLoginInfoAsync 总是返回 null

我有ASP.NET5项目,我正在使用WebAPI建立外部登录(用于Facebook和Google)。就我而言,我有包含以下代码的WebAPIController(不是MVCController):[OverrideAuthentication][HostAuthentication(DefaultAuthenticationTypes.ExternalCookie)][AllowAnonymous][Route("ExternalLogin",Name="ExternalLogin")]publicasyncTaskGetExternalLogin(stringprovider,str

c# - ASP.Net Core 1 日志记录错误 - 无法找到来自源应用程序的事件 ID xxxx 的描述

我想从ASP.NetCore应用程序的Controller方法写入Windows事件日志。我遇到的问题是,在我希望写入日志信息的地方,我不断收到错误/信息日志:ThedescriptionforEventIDxxxxfromsourceApplicationcannotbefound.Eitherthecomponentthatraisesthiseventisnotinstalledonyourlocalcomputerortheinstallationiscorrupted.Youcaninstallorrepairthecomponentonthelocalcomputer.If

c# - 将 Office 2010 Web 应用程序与 ASP.NET 结合使用

是否可以将Office2010网络应用程序与ASP.NET应用程序一起使用?例如:-对于我的ASP.NET应用程序的每个用户,我的服务器上都有一个包含Word文档的文件夹-ASP.NET应用程序在网格中向用户显示可用文档-单击网格中的其中一个文档时,Word文档将加载到包含Office2010网络应用程序Word界面的IFrame中,并且可以对文档进行编辑-编辑后,文档可以保存到服务器,ASP.NET网格显示更新状态这样的场景是否可能?你需要什么,例如Sharepoint、Office2010许可证? 最佳答案 我认为您会想看看Sh